<?php

abstract class Base_Abstract implements ArrayAccess {

	protected $_data = array();

	public function __get ($name) {
		if (is_array($name)) $name = $name[0];
		return $this[$name];
	}

	public function __set ($name, $value = false) {
		if (is_array($name)) {
			$value = $name[1];
			$name = $name[0];
		}
		$this[$name] = $value;
	}

	public function __isset ($name) {
		if (is_array($name)) $name = $name[0];
		isset($this[$name]);
	}

	public function __unset ($name) {
		if (is_array($name)) $name = $name[0];
		unset($this[$name]);
	}

	public function offsetSet ($offset, $value) {
		if (is_null($offset)) {
			$this->_data[] = $value;
		} else {
			$this->_data[$offset] = $value;
		}
	}

	public function offsetExists ($offset) {
		return isset($this->_data[$offset]);
	}

	public function offsetUnset ($offset) {
		unset($this->_data[$offset]);
	}

	public function offsetGet ($offset) {
		if (!isset($this->_data[$offset])) {
			//trigger_error("Unknown offset `{$offset}`", E_USER_NOTICE);
			return null;
		} else {
			return $this->_data[$offset];
		}
	}

}